{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='Date'>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAisAAAGKCAYAAADNBgH+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAA9dUlEQVR4nO3deXxVd53/8dcnOwkJgSQsCTsk7DS00a5QutpibQAddaxaHX/WraN176JttaXtWMdtZnRE7VQdpnZGC3RvrV3obkNJ2XcIJAGysQRC9s/vj3tLw5oQkpyb3Pfz8eij937vOed+LgHum+/5ns8xd0dEREQkUsUEXYCIiIjIqSisiIiISERTWBEREZGIprAiIiIiEU1hRURERCJaXNAFtCczM9NHjx4ddBkiIiLSBZYvX17l7lmns0/Eh5XRo0dTVFQUdBkiIiLSBcys5HT30WkgERERiWgKKyIiIhLRFFZEREQkokX8mhUREZGe1NTURGlpKfX19UGX0qslJSUxfPhw4uPjz/hYCisiIiJtlJaWkpqayujRozGzoMvpldyd6upqSktLGTNmzBkfT6eBRERE2qivrycjI0NB5QyYGRkZGV02O6WwIiIicgwFlTPXlb+GCisiIiIS0RRWREREJKIprIiIiESQ7du3M3Xq1KPG7rzzTn784x8D8MYbb3DuueeSn5/PpEmTuPPOOwF48MEHycrKYsaMGeTm5vKBD3yA11577aTv87Of/Yw//OEPAHzmM59hzJgx5Ofnc/bZZ/P6668fGU9OTqa2tvbIfjfddBNmRlVVFY2NjcyaNYvm5uau/CU4jsKKiIhIL3L99dezcOFCiouLWb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j4VkLrVv4XGAmUAB919xozGwoUAWnh7Q8Ck939gJnlA78FEoCtwGfdfW8PfhwRERHpZupgKyIiIhFNHWxFREQkoimsiIiISERTWBEREZGIprAiIiIiEU1hRURERCKawoqIdBszazGz4vAd1t8xs2+a2Sn/3jGz0Wb2iZ6qUUQin8KKiHSnw+6e7+5TgCuAq4E72tlnNKCwIiJHqM+KiHQbMzvo7v3bPB8LvAVkAqOAPwLv3oD0Rnd/zczeACYB2wjdgf0XwH3AbCAR+A93/3WPfQgRCZzCioh0m2PDSnhsHzABqAVa3b3ezHKBh9y9wMxmA99y92vC298ADHb3u80sEXgV+Ad339aDH0VEAhQXdAEiErXigX8P3zajBcg7yXZXAtPN7CPh5wOAXEIzLyISBRRWRKTHhE8DtRC6q/odwB7gLELr5+pPthvwz+7+TI8UKSIRRwtsRaRHmFkW8J/Av3vo/PMAYJe7twKfAmLDm9YCqW12fQb4kpnFh4+TZ2YpiEjU0MyKiHSnfmZWTOiUTzOhBbU/Cb/2S+AvZvZp4GngUHh8JdBiZu8ADwI/J3SF0NtmZkAlMLdnyheRSKAFtiIiIhLRdBpIREREIprCioiIiEQ0hRURERGJaAorIiIiEtEUVkRERCSiKayIiIhIRFNYERERkYj2/wHWzNG1/2W3HAAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 648x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "gold_data=pd.read_csv('LBMA-GOLD.csv',parse_dates=['Date'],index_col='Date')[:5]\n",
    "gold_data.plot(figsize=(9,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2016-09-12', '2016-09-13', '2016-09-14', '2016-09-15',\n",
       "               '2016-09-16', '2016-09-19', '2016-09-20', '2016-09-21',\n",
       "               '2016-09-22', '2016-09-23', '2016-09-26', '2016-09-27',\n",
       "               '2016-09-28', '2016-09-29', '2016-09-30', '2016-10-03',\n",
       "               '2016-10-04', '2016-10-05', '2016-10-06', '2016-10-07'],\n",
       "              dtype='datetime64[ns]', name='Date', freq=None)"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gold_data.index"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "level check"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1323.65"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gold_data['USD (PM)'][1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n=len(gold_data)\n",
    "lambda_k=np.zeros(n-1)\n",
    "for i in range(n-1):\n",
    "    lambda_k[i]=gold_data['USD (PM)'][i]/gold_data['USD (PM)'][i+1]\n",
    "    if lambda_k[i]<np.exp(-2/(n+1)) or lambda_k[i]>np.exp(2/(n+2)):\n",
    "        flag=False\n",
    "        print(flag)\n",
    "    else:\n",
    "        flag=True\n",
    "\n",
    "flag"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>USD (PM)</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016-09-12</th>\n",
       "      <td>1324.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-13</th>\n",
       "      <td>1323.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-14</th>\n",
       "      <td>1321.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-15</th>\n",
       "      <td>1310.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-16</th>\n",
       "      <td>1308.35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-19</th>\n",
       "      <td>1314.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-20</th>\n",
       "      <td>1313.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-21</th>\n",
       "      <td>1326.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-22</th>\n",
       "      <td>1339.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-23</th>\n",
       "      <td>1338.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-26</th>\n",
       "      <td>1340.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-27</th>\n",
       "      <td>1327.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-28</th>\n",
       "      <td>1322.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-29</th>\n",
       "      <td>1318.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-30</th>\n",
       "      <td>1322.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-10-03</th>\n",
       "      <td>1313.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-10-04</th>\n",
       "      <td>1283.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-10-05</th>\n",
       "      <td>1269.40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-10-06</th>\n",
       "      <td>1254.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-10-07</th>\n",
       "      <td>1258.75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            USD (PM)\n",
       "Date                \n",
       "2016-09-12   1324.60\n",
       "2016-09-13   1323.65\n",
       "2016-09-14   1321.75\n",
       "2016-09-15   1310.80\n",
       "2016-09-16   1308.35\n",
       "2016-09-19   1314.85\n",
       "2016-09-20   1313.80\n",
       "2016-09-21   1326.10\n",
       "2016-09-22   1339.10\n",
       "2016-09-23   1338.65\n",
       "2016-09-26   1340.50\n",
       "2016-09-27   1327.00\n",
       "2016-09-28   1322.50\n",
       "2016-09-29   1318.10\n",
       "2016-09-30   1322.50\n",
       "2016-10-03   1313.30\n",
       "2016-10-04   1283.30\n",
       "2016-10-05   1269.40\n",
       "2016-10-06   1254.50\n",
       "2016-10-07   1258.75"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gold_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "n=len(gold_data)\n",
    "lambda_k=np.zeros(n-1)\n",
    "# c_list=[i/10 for i in range(-20000,20001)]\n",
    "c_list=[0]\n",
    "for c in c_list:\n",
    "    data=gold_data+c\n",
    "    flag_list=[]\n",
    "    for i in range(n-1):\n",
    "        lambda_k[i]=data['USD (PM)'][i]/data['USD (PM)'][i+1]\n",
    "        if lambda_k[i]<np.exp(-2/(n+1)) or lambda_k[i]>np.exp(2/(n+2)):\n",
    "            flag=False\n",
    "        else:\n",
    "            flag=True\n",
    "        flag_list.append(flag)\n",
    "    if not False in flag_list:\n",
    "        print(c)\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "x0=gold_data['USD (PM)']\n",
    "y0=data['USD (PM)']\n",
    "x0=np.array(x0)\n",
    "x1=np.cumsum(x0)\n",
    "\n",
    "x1=pd.DataFrame(x1)\n",
    "z1=(x1+x1.shift())/2.0\n",
    "z1=z1[1:].values.reshape((len(z1)-1,1))\n",
    "B=np.append(-z1,np.ones_like(z1),axis=1)\n",
    "Y=x0[1:].reshape((len(x0)-1,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "[[a],[b]]=np.dot(np.dot((np.linalg.inv(np.dot(B.T,B))),B.T),Y)\n",
    "f=lambda k:(x0[0]-b/a)*np.exp(-a*(k-1))-(x0[0]-b/a)*np.exp(-a*(k-2))\n",
    "x1_pre = [f(k) for k in range(1,len(x0)+1)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "检验"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.01081263 0.00939332 0.00870101 0.01497074 0.01471527 0.00755812\n",
      " 0.00622532 0.00522147 0.01696756 0.01872214 0.02215413 0.01430063\n",
      " 0.01304375 0.01184879 0.01722463 0.01243843 0.00850514 0.01738656\n",
      " 0.0272875  0.02164819]\n",
      "[0.0014041255389125595, 0.0006858758988014246, -0.0062156485592312904, 0.0002516990153550447, 0.0070533639823381344, 0.0013228023193325722, 0.011375968143566562, 0.01180774493600445, 0.001784869348767093, 0.0034974719966133216, -0.008031436476010567, -0.0012751156685546494, -0.001210744172922551, 0.005440293924098283, -0.004870084439449807, -0.021207347309974534, -0.008806521417464186, -0.009731742273244803, 0.005489522627694088]\n"
     ]
    }
   ],
   "source": [
    "delta = np.abs(x0 - np.array([f(i) for i in range(1,len(x0)+1)]))\n",
    "residual_error = np.abs((x0-np.array(x1_pre))/x0)\n",
    "residual_error_max = residual_error.max\n",
    "print(residual_error)\n",
    "p = [1-((1-0.5*a)/(1+0.5*a))*l for l in lambda_k]\n",
    "print(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "检验结果成立"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "下一天的预测值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1338.9224107338814"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1_pre[0]"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "b5fc3e43e814ad01a3162358639356c8d5269fa9e7a0a06af2b9cdf0ba130cad"
  },
  "kernelspec": {
   "display_name": "Python 3.8.8 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
